package com.situ.mall.observer;

public class Reader implements Observer {
    private String name;

    public Reader(String name) {
        this.name = name;
    }

    //观察者的状态
    private String content;

    //update传入目标对象Subject，当需要目标对象Subject的属性和方法可以直接调用
    @Override
    public void update(Subject subject) {
        //虽然传入的是Subject父类，NewsPaper
        //强制转换成NewsPaper，调用具体子类的状态
        content = ((NewsPaper) subject).getContent();
        System.out.println(name + "收到报纸，本期内容是：" +content);
    }
}
